<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <p>1</p>
  <p>2</p>
  <p>3</p>
  <script>
  //常见的类数组的解构赋值
  function fun(){
    console.log(arguments);
    console.log(arguments.push);
    const [a,b,c]=arguments
    console.log(a,b,c);
  }
  fun(1,2,3)
  const [p1,p2,p3]=document.querySelectorAll('p')
  console.log(p1,p2,p3);
  //2.函数参数的解构赋值
  const arr=[1,2]
  const add=([x=0,y=0])=>x+y;
  console.log(add(arr));
  console.log(add([]));
  //3.交换变量的值
  let x=1
  let y=2;
  /* let temp=x
  x=y
  y=temp
  console.log(x,y); */
  [y,x]=[x,y]
  console.log(x,y);
</script>
</body>
</html>